package service

import (
	"context"
	__ "video-srv/basic/proto"
	"video-srv/handler/model"
)

type Server struct {
	__.UnimplementedVideoServer
}

func (s *Server) AddMember(_ context.Context, in *__.AddMemberReq) (*__.AddMemberResp, error) {

	return &__.AddMemberResp{}, nil
}

func (s *Server) GetListVideo(_ context.Context, in *__.ListVideoReq) (*__.ListVideoResp, error) {
	return &__.ListVideoResp{}, nil
}

func (s *Server) AddVideo(_ context.Context, in *__.AddVideoReq) (*__.AddVideoResp, error) {

	var video model.Video

	video = model.Video{
		Title:       in.Title,
		Image:       in.Image,
		Info:        in.Info,
		VideoListId: int32(in.VideoListId),
	}

	err := video.AddVideo()
	if err != nil {
		return nil, err
	}

	return &__.AddVideoResp{VideoId: int64(video.Id)}, nil
}
